package agency.web.app.repository.impl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import agency.web.app.domain.User;
import agency.web.app.repository.UserDao;
import agency.web.app.repository.base.AbstractHibernateDao;

@Repository
public class UserRepository extends AbstractHibernateDao<User,Integer> implements UserDao{

	public User userRegistration(String login, String password) {
		Criteria cr = getSession()
				.createCriteria(User.class, "users")
				.add(Restrictions.eq("login", login))
				.add(Restrictions.eq("password", password));
		return (User) cr.uniqueResult();
	}
	
	public User findById(int userId) {
		Criteria cr = getSession()
				.createCriteria(User.class, "users")
				.add(Restrictions.eq("id", userId));
		return (User) cr.uniqueResult();
	}

	
	

}
